class CreateMemberships < ActiveRecord::Migration
  def self.up
    create_table :memberships do |t|
			t.integer :user_id, :null=>false
			t.integer :community_id, :null=>false
			t.integer :role_id, :null=>false, :default=>Role.detect(Role::DEFAULT).id
      t.timestamps
    end
    
    add_index :memberships, [:user_id], :name=>"fk_user"
    add_index :memberships, [:community_id], :name=>"fk_community"
  end

  def self.down
    drop_table :memberships
  end
end
